﻿using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using TrackSystem.Entities.Extensions;

namespace TrackSystem.Entities.Models
{
    /// <summary>
    /// 报警记录数据库
    /// </summary>
    [Table("alarm")]
    public class AlarmTable
    {
        /// <summary>
        /// 统一标识符
        /// </summary>
        [Key]
        [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        [Display(Name = "统一标识符")]
        public int Id { get; init; }
        
        /// <summary>
        /// 唯一识别号
        /// </summary>
        public Guid Identify { get; set; }

        /// <summary>
        /// 报警首次发送时间
        /// </summary>
        public DateTime CreateDt { get; set; }

        /// <summary>
        /// 报警发生时间
        /// </summary>
        public DateTime HappenDt { get; set; }

        /// <summary>
        /// 报警内容
        /// </summary>
        public string? Description { get; set; }

        /// <summary>
        /// 报警来源类型
        /// </summary>
        public AlarmCategory SourceType { get; set; }

        /// <summary>
        /// 报警来源名称
        /// </summary>
        public string? SourceName { get; set; }

        /// <summary>
        /// 发生报警时的值
        /// </summary>
        public string? Value { get; set; }

        /// <summary>
        /// 发生同样报警的次数
        /// </summary>
        public int Counter { get; set; }

        /// <summary>
        /// 确认标志
        /// </summary>
        public bool Confirm { get; set; }

        /// <summary>
        /// 确认时间
        /// </summary>
        public DateTime ConfirmDt { get; set; }

        /// <summary>
        /// 是否隐藏该报警,隐藏后如果出现比当前报警值更高（高报）或更低（低报）时候，将取消隐藏功能
        /// </summary>
        public bool Hidden { get; set; }

        /// <summary>
        /// 隐藏后在这个设置范围内不重新启动报警
        /// </summary>
        public double Range { get; set; }
    }
}
